package chap6.task3;

import sun.awt.image.BufferedImageDevice;

import java.io.*;

/**
 * @author banana
 * 创建字节缓冲流对象,通过缓冲流对象实现信息写入文件，以及读取文件内容
 */
public class Task6_4 {
    public static void main(String[] args) throws Exception {
       //第一种
        /*OutputStream out=new FileOutputStream("a");
        BufferedOutputStream bos=new BufferedOutputStream(out);*/
       //第二种
        BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("a"));
        String s="poop";
        bos.write(s.getBytes());
        bos.close();
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("a"));
        byte[] bys=new byte[1024];
        int len=0;
        while((len=bis.read(bys))!=-1){
            System.out.println(new String(bys,0,len));
        }

    }
}
